package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.HousekeepingEnclosure;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Housekeeping;
import com.ruoyi.system.service.IHousekeepingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家政人员管理Controller
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@RestController
@RequestMapping("/system/housekeeping")
public class HousekeepingController extends BaseController
{
    @Autowired
    private IHousekeepingService housekeepingService;

    /**
     * 查询家政人员管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:housekeeping:list')")
    @GetMapping("/list")
    public TableDataInfo list(Housekeeping housekeeping, HousekeepingEnclosure housekeepingEnclosure)
    {
        startPage();
        housekeeping.setHousekeepingEnclosure(housekeepingEnclosure);
        List<Housekeeping> list = housekeepingService.selectHousekeepingList(housekeeping);
        return getDataTable(list);
    }

    /**
     * 导出家政人员管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:housekeeping:export')")
    @Log(title = "家政人员管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Housekeeping housekeeping)
    {
        List<Housekeeping> list = housekeepingService.selectHousekeepingList(housekeeping);
        ExcelUtil<Housekeeping> util = new ExcelUtil<Housekeeping>(Housekeeping.class);
        return util.exportExcel(list, "housekeeping");
    }

    /**
     * 获取家政人员管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:housekeeping:query')")
    @GetMapping(value = "/{hId}")
    public AjaxResult getInfo(@PathVariable("hId") Long hId)
    {
        return AjaxResult.success(housekeepingService.selectHousekeepingById(hId));
    }

    /**
     * 新增家政人员管理
     */
//    @PreAuthorize("@ss.hasPermi('system:housekeeping:add')")
    @Log(title = "家政人员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Housekeeping housekeeping)
    {
        return toAjax(housekeepingService.insertHousekeeping(housekeeping));
    }

    /**
     * 修改家政人员管理
     */
//    @PreAuthorize("@ss.hasPermi('system:housekeeping:edit')")
    @Log(title = "家政人员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Housekeeping housekeeping)
    {
        return toAjax(housekeepingService.updateHousekeeping(housekeeping));
    }

    /**
     * 删除家政人员管理
     */
//    @PreAuthorize("@ss.hasPermi('system:housekeeping:remove')")
    @Log(title = "家政人员管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hIds}")
    public AjaxResult remove(@PathVariable Long[] hIds)
    {
        return toAjax(housekeepingService.deleteHousekeepingByIds(hIds));
    }
}
